﻿@{
    Layout = null;
}
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>菜单编辑页面</title>
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/jqueryEasyui/js")
    @Styles.Render("~/jqueryEasyui/css")
    @Scripts.Render("~/Validform/js")
    @Styles.Render("~/Validform/css")
    <script type="text/javascript">

        //页面加载
        $(function () {
            var editData = $.ifdata("editData");

            //初始化表单提交
            $(".registerform").Validform({
                tiptype: 2,
                postonce: true,
                ajaxPost: true,
                callback: function (data) {
                    if (data.status == "y") {
                        $.messager.alert("系统提示", data.info, "info", function () {
                            window.parent.$("#menuForm").dialog("close");
                        })
                    } else {
                        $.messager.alert("系统提示", data.info, "info");
                    }
                }
            });

            //只绘制TreeGrid , TreeGrid的数据在Combobox数据加载完成后，初始化选择项目时onSelect中执行，
            $('#tg').treegrid({
                url: '/adminweb/menu/GetTreeNotInCurrent?cid=' + (editData == undefined ? "" : editData.ID),
                idField: 'ID',
                treeField: 'Name',
                height: $("#classList").height(),
                columns: [[
                        { title: '请选择所属父类', field: 'Name', width: 280 }
                ]],
                onClickRow: tg_onClickRow,
                onLoadSuccess: function (row, data) {
                    if (data.length > 0) {
                        //编辑时，数据初始化
                        if (editData != null && editData != undefined) {
                            $("#C_Name").val(editData.Name);
                            $("#C_Url").val(editData.Url);
                            $("#C_Order").val(editData.Order);
                            $("#C_ID").val(editData.ID);
                            $('#tg').treegrid("select", editData.PID);
                            var r = $('#tg').treegrid("find", editData.PID);
                            tg_onClickRow(r);
                        } else {
                            //默认选择中第一行
                            $('#tg').treegrid("select", data[0].ID);
                            var r = $('#tg').treegrid("find", data[0].ID);
                            tg_onClickRow(r);
                        }
                    }
                }
            });

        });

        var btn_Submit = function () {
            $("form").submit();
        }

        //行 click事件
        var tg_onClickRow = function (row) {
            $("#Pname").val(row.Name);
            $("#C_Parent_ID").val(row.ID);
            $("#Pname").blur();
        }
    </script>
</head>
<body>
    <form id="form1" class="registerform" action="@ViewData["action"]">
        <div style="width: 790px;">
            <div id="classList" style="float: left; width: 300px; height: 300px;">
                <table id="tg" class="easyui-treegrid">
                </table>
            </div>
            <div style="float: left; width: 470px; clear: none; margin-left: 20px;">
                <table>
                    <tr>
                        <td>
                            <span style="color: Red">*&nbsp;</span>所属父类：
                        </td>
                        <td style="padding-right: 7px;">
                            <input type="text" id="Pname" disabled="disabled" readonly="readonly" name="Pname"
                                class="inputxt" datatype="*1-40" nullmsg="请选择所属上级菜单" errormsg="长度为1~40，请输入正确的字符串长度"
                                style="width: 100%;" />
                            <input type="hidden" id="C_Parent_ID" name="C_Parent_ID" />
                        </td>
                        <td>
                            <div class="Validform_checktip">
                                请选择上级菜单
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span style="color: Red">*&nbsp;</span>菜单名称：
                        </td>
                        <td style="padding-right: 7px;">
                            <input type="text" id="C_Name" name="C_Name" class="inputxt" datatype="*1-40" nullmsg="请输入菜单名称！"
                                errormsg="长度为1~40的，请输入正确的字符串长度" style="width: 100%;" />
                        </td>
                        <td>
                            <div class="Validform_checktip">
                                请输入菜单名称
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span style="color: White">*&nbsp;</span>链接地址：
                        </td>
                        <td>
                            <textarea rows="4" id="C_Url" style="font-size: 12px;" name="C_Url" cols="25"></textarea>
                        </td>
                        <td>
                            <div class="Validform_checktip" style="height: auto;">
                                输入菜单链接地址，为空时无链接。<br />
                                格式：/admin/system/xx.aspx
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="clear">
            </div>
            <div class="aui_buttons" style="height: 35px; text-align:right;">
                <a href="#" class="easyui-linkbutton" style="margin-right:64px; margin-top:-140px;" data-options="plain:true,iconCls:'icon-save'" onclick="$('form').submit()">保 存</a>
                <input type="hidden" id="C_Order" name="C_Order" value="" />
                <input type="hidden" id="C_ID" name="C_ID" value="" />
            </div>
        </div>
        
    </form>
</body>
</html>
